package com.free.mini.core.serve.controller;

import com.free.mini.core.server.vo.req.StudyQuestionUpdateReqVO;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.free.mini.common.base.ResultData;
import com.free.mini.core.serve.service.IStudyQuestionService;
import com.free.mini.core.server.vo.req.StudyQuestionCreateReqVO;
import com.free.mini.core.server.vo.req.StudyQuestionListQueryReqVO;
import com.free.mini.core.server.vo.req.StudyQuestionQueryDetailReqVO;
import com.free.mini.core.server.vo.resp.StudyQuestionListQueryRespVO;
import com.free.mini.core.server.vo.resp.StudyQuestionQueryDetailRespVO;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * @author dongsufeng
 * @version 4.0
 * @date 2023/7/31 11:59
 */
@RestController
@RequestMapping("study/v1/app/question")
@Slf4j
@RequiredArgsConstructor
public class StudyQuestionController {

    private final IStudyQuestionService studyQuestionService;

    /**
     * 查询题目列表
     */
    @PostMapping("/list")
    public ResultData<Page<StudyQuestionListQueryRespVO>> list(@RequestBody @Validated StudyQuestionListQueryReqVO reqVO){
        return ResultData.data(studyQuestionService.page(reqVO));
    }

    @PostMapping("/detail")
    public ResultData<StudyQuestionQueryDetailRespVO> detail(@RequestBody @Validated StudyQuestionQueryDetailReqVO reqVO){
        return ResultData.data(studyQuestionService.detail(reqVO));
    }

    /**
     * 录入题目
     * @param reqVO
     * @return
     */
    @PostMapping("/create")
    public ResultData<Boolean> create(@RequestBody @Validated StudyQuestionCreateReqVO reqVO){
        return ResultData.data(studyQuestionService.createStudyQuestion(reqVO));
    }
    @PostMapping("/update")
    public ResultData<Boolean> update(@RequestBody @Validated StudyQuestionUpdateReqVO reqVO){
        return ResultData.data(studyQuestionService.updateStudyQuestion(reqVO));
    }
}
